﻿using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace Mozhi.Abp.Module.DataLinkage
{
    public class DataLinkage : AuditedAggregateRoot<Guid> , IMultiTenant
    {
        public Guid? TenantId {  get; private set; }

        /// <summary>
        /// 数据提供者
        /// </summary>
        public Guid ProviderId { get; private set; }

        public string ProviderType { get; private set; }

        public string ProviderContent {  get; private set; }

        /// <summary>
        /// 数据使用者
        /// </summary>
        public Guid ConsumerId {  get; private set; }

        public string ConsumerType { get; private set; }

        public string ConsumerContent { get; private set; }

        public DataLinkage(Guid id, Guid providerId, string providerContent, Guid consumerId, string consumerContent, string providerType, string consumerType)
        {
            Id = id;
            ProviderId = providerId;
            ProviderContent = providerContent;
            ConsumerId = consumerId;
            ConsumerContent = consumerContent;
            ProviderType = providerType;
            ConsumerType = consumerType;

            Validate();
            
        }

        #region
        private void Validate()
        {
            Check.NotDefaultOrNull<Guid>(ProviderId, nameof(ProviderId));
            Check.NotDefaultOrNull<Guid>(ConsumerId, nameof(ProviderId));
            Check.NotNullOrEmpty(ConsumerContent, nameof(ConsumerContent));
            Check.NotNullOrEmpty(ProviderType, nameof(ProviderType));
            Check.NotNullOrEmpty(ConsumerType, nameof(ConsumerType));
        }
        #endregion
    }
}
